<?php
class planecontroller extends AppController
{
	var $name = 'Plane';
	var $uses = array('Plane');  //使用Plane这个model
	//beforeFilter 页面执行前执行
	//afterFilter 页面执行后执行
	//beforeRender 页面显示前执行
	//afterRender 页面显示后执行
	
	//显示空白页面
	function index(){   }
	
    //获取所有飞机信息
	function getAll()
	{
		$plane = $this->Plane->find('all');
		return $plane ;
	}
	
	//添加飞机    
	//输入：飞机型号，头等舱座位数，公务舱座位数，经济舱座位数
	//头等舱座位情况，公务舱座位情况，经济舱座位情况 
	//返回：添加成功或者失败原因
	function addPlane($model, $first_class, $second_class,$third_class,
					  $first_info, $second_info, $third_info)
	{
		$plane = array ('Plane'=>
						array('model'=>$model,
							  'first_class'=>$first_class,
							  'second_class'=>$second_class,
							  'third_class'=>$third_class,
							  'first_info'=>$first_info,
							  'second_info'=>$second_info,
							  'third_info'=>$third_info
							  )
						);
		if ($this->Plane->save($plane,false))
		{
			return true ;
		}
		else
		{
			return false ;
		}
		
	}
	
	//删除飞机  输入：飞机ID 输出：返加成功或者失败原因
	function delPlane($id)
	{
		if(!empty($id))
		{
			$this->Plane->id = $id;
			$this->Plane->del($id);
			return true ;
		}
		else
	    {
		return false;
		}
	}
	
	//修改飞机信息  
	//输入：飞机id，飞机型号， 
	//返回：修改成功或者失败原因
	function motifyPlane($id,$model,$first_class,$second_class,
						 $third_class,$first_info,$second_info,$third_info)
	{
		if(!empty($id)){
			$this->Plane->id = $id;
			$plane = array ('Plane'=>
						array('model'=>$model,
							  'first_class'=>$first_class,
							  'second_class'=>$second_class,
							  'third_class'=>$third_class,
							  'first_info'=>$first_info,
							  'second_info'=>$second_info,
							  'third_info'=>$third_info
							  )
						);
			//测试数据是否保存
			if ($this->Plane->save($plane,false)){
				return true;
			}
			else 
			{
				return false;
			}
		}
		else
		{
			return 'false1';
		}
		
	}
	
}
?>
